package com.enen.demo.web.controller;

import com.enen.demo.bean.Article;
import com.enen.demo.bean.Category;
import com.enen.demo.service.IArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/Article")
@RestController
public class ArticleController {
    @Autowired
    private IArticleService service;

    @PostMapping("/saveOrUpdate")
    public String saveOrUpdate(Article article){
        service.saveOrUpdate(article);
        return "保存成功";
    }

    @GetMapping("/findAll")
    public List<Article> findAll(){
        return  service.findAll();
    }

    @GetMapping("/findArticle")
    public Article findArticleyById(long id){
        return service.findArticleById(id);
    }

    @GetMapping("/removeArticle")
    public String removeArticle(long id){
        service.removeArticle(id);
        return "删除成功";
    }
}
